home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / lib / backup / stest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  1.4 KB  |  72 lines

  1.  
  2. /* speed test program for arrays rnts  */
  3.  
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6.  
  7. /*****************************************************/
  8. main(argc, argv)
  9.     int       argc;
  10.     char    **argv;
  11. {
  12.     u_char ***image;
  13.     int       rw, cl, nf;
  14.     register int c, r, f, i;
  15.     register u_char *bptr, *gptr;
  16.     int       npix;
  17.  
  18.     long      tbuf[4], ut1, ut2;
  19.  
  20.     u_char ***alloc_3d_byte_array();
  21.  
  22.     rw = 50;
  23.     cl = 50;
  24.     nf = 50;
  25.     npix = nf * rw * cl;
  26.  
  27.     fprintf(stderr, "\n size: rows: %d,  cols: %d,  frames: %d \n", rw, cl, nf);
  28.  
  29.     image = alloc_3d_byte_array(nf, rw, cl);
  30.  
  31.     /* speed test #1  */
  32.  
  33.     times(tbuf);
  34.     ut1 = tbuf[0];
  35.  
  36.     bptr = **image;
  37.  
  38.     for (i = 0; i < npix; i++) {
  39.     *(bptr++) = 100;
  40.     }
  41.  
  42.     times(tbuf);
  43.     ut2 = tbuf[0];
  44.     fprintf(stderr, "result method 1: user time was =%d\n", ut2 - ut1);
  45.  
  46.     times(tbuf);
  47.     ut1 = tbuf[0];
  48.     bptr = **image;
  49.  
  50.     for (i = 0; i < npix; i++) {
  51.     bptr[i] = 100;
  52.     }
  53.  
  54.     times(tbuf);
  55.     ut2 = tbuf[0];
  56.     fprintf(stderr, "result method 2: user time was =%d\n", ut2 - ut1);
  57.  
  58.     times(tbuf);
  59.     ut1 = tbuf[0];
  60.     for (f = 0; f < nf; f++)
  61.     for (r = 0; r < rw; r++)
  62.         for (c = 0; c < cl; c++)
  63.         image[f][r][c] = 100;
  64.  
  65.     times(tbuf);
  66.     ut2 = tbuf[0];
  67.     fprintf(stderr, "result method 3: user time was =%d\n", ut2 - ut1);
  68.  
  69.     fprintf(stderr, "\n\n finished. \n\n");
  70.     return (0);
  71. }
  72.